<?php
/*
Primary Author: Derek Shue
Secondary: Sean Margison, Alex Arey
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Add Course form is used by teachers to add new courses to the database.
*/

class Application_Form_AddCourse extends Zend_Form {
public function init() {
// $auth=Zend_Auth::getInstance();
// $rank=$auth->getIdentity()->getUserRank();

// $term = new Application_Model_Term();
// $options = $term->getAllTerms();
// $termoptions = array();


// foreach($options as $opt){
// 	$termoptions[$opt['TERM'] . $opt['YEAR'] ] = $opt['TERM'].$opt['YEAR'];
// }
	$shortTextLenValid = new Zend_Validate_StringLength(array('max'=>8));
	$longTextLenValid = new Zend_Validate_StringLength(array('max' => 120));
	$medLongTextLenValid = new Zend_Validate_StringLength(array('max' => 1000));
	$reallyLongTextLenValid = new Zend_Validate_StringLength(array('max' => 2000));
	$phonevalid = new Zend_Validate_Regex(array('pattern' => '/^\(\d\d\d\) ?\d\d\d-\d\d\d\d$/'));

$this->setMethod('post');
$this->addElement('text','COURSENAME',array('label'=>'Course Name:','required'=>true,));

$val_name = new Zend_Validate_Regex(array('pattern'=>'/^([a-zA-z \'\-]*)$/'));
$val_name->setMessage('Must consist of characters, dashes, or apostrophies');
$this->getElement('COURSENAME')->addValidator($val_name, $longTextLenValid);

$this->addElement('text','DEPARTMENT',array('label'=>'Department (ex. COMP, BIOL, CHEM):','required'=>true,));

$val_dept = new Zend_Validate_Regex(array('pattern'=>'/^([A-Z]*)$/'));
$val_dept->setMessage('Must consist of capitalized characters');
$this->getElement('DEPARTMENT')->addValidator($val_dept, $shortTextLenValid);

$this->addElement('text','COURSENUMBER',array('label'=>'Course Number:','required'=>true,));

$val_num = new Zend_Validate_Regex(array('pattern'=>'/^([0-9]*)$/'));
$val_num->setMessage('Must consist of only numbers');
$this->getElement('COURSENUMBER')->addValidator($val_num, $shortTextLenValid);

$this->addElement('textarea','DESCRIPTION',
	array('label'=>'Course Description:','required'=>true,'validators'=>array($reallyLongTextLenValid)));

/*
The form dynamically displays the available Terms that a course can be added to. 
*/
//$this->addElement('radio','TERM',array('label'=>'Term:','multiOptions'=> $termoptions, 'required'=>true,));
$this->addElement('text','SYLLABUS',array('label'=>'Syllabus URL: (include \'http://\')','required'=>true,'validators'=>array($medLongTextLenValid)));

$this->addElement('submit','submit',array('label'=>'Submit Request'));
}
}
?>
